package com.witmore.skyline.web.service;

/**
 * 地区数据导入服务
 *
 * @author 豆子高
 * @since 2025-10-22
 */
public interface RegionDataImportService {

    /**
     * 从JSON文件导入地区数据
     *
     * @return 导入结果统计
     */
    RegionImportResult importRegionDataFromJson();

    /**
     * 清空现有地区数据
     *
     * @return 清空的记录数
     */
    int clearRegionData();

    /**
     * 获取地区数据统计
     *
     * @return 统计信息
     */
    RegionStatistics getRegionStatistics();

    /**
     * 填充完整名称
     * 根据 acroutes 父级路径拼凑出完整的地区名称
     *
     * @return 更新结果统计
     */
    RegionImportResult fillFullNames();

    /**
     * 地区数据导入结果
     */
    @lombok.Getter
    @lombok.Setter
    class RegionImportResult {
        private int totalCount;
        private int successCount;
        private int failCount;
        private long costTime;
        private String message;

        public RegionImportResult(int totalCount, int successCount, int failCount, long costTime, String message) {
            this.totalCount = totalCount;
            this.successCount = successCount;
            this.failCount = failCount;
            this.costTime = costTime;
            this.message = message;
        }
    }

    /**
     * 地区数据统计
     */
    @lombok.Getter
    @lombok.Setter
    class RegionStatistics {
        private int countryCount;
        private int provinceCount;
        private int cityCount;
        private int districtCount;
        private int totalCount;

        public RegionStatistics(int countryCount, int provinceCount, int cityCount, int districtCount) {
            this.countryCount = countryCount;
            this.provinceCount = provinceCount;
            this.cityCount = cityCount;
            this.districtCount = districtCount;
            this.totalCount = countryCount + provinceCount + cityCount + districtCount;
        }
    }
}
